# -*- coding:utf-8 -*-
class Solution:
    def PrintMinNumber(self, numbers):
        # write code here
        res = []
        numbers = [str(i) for i in numbers]# list(map(str, numbers))
        print(numbers)
        for i in range(len(numbers)):
            if not res:
                res.append(numbers[i])
            else:
                min = ''.join(res) + numbers[i]
                # print('inital min is {}'.format(min))
                min_index = len(res)
                for j in range(len(res)):
                    cur = ''.join(res[:j]) + numbers[i] + ''.join(res[j:])
                    # print('cur is {}'.format(cur))
                    if  cur < min:
                        min = cur
                        min_index = j
                res.insert(min_index, numbers[i])
            # print(res)



        return int(''.join(res))
test = Solution()
print(test.PrintMinNumber([3,5,1,4,2]))